﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace Guru.Web.Controls.Validators
{
    public class Invoker
    {
        protected const string _APP_GLOBAL_FOLDER_NAME = "App_GlobalResources";

        public static string GetGlobalResourceValue(string typeName, string propertyName)
        {
            System.Reflection.Assembly assembly = global::System.Reflection.Assembly.Load(_APP_GLOBAL_FOLDER_NAME);           
            Type type = assembly.GetType(typeName);
            if (type == null) throw new ResourceNotFound(typeName);
            PropertyInfo property = type.GetProperty(propertyName);
            if (property == null) throw new ResourceNotFound(string.Format("{0}.{1}", typeName, propertyName));
            return (string)property.GetValue(type, null);
        
        }
    }
}
